import { createSlice } from "@reduxjs/toolkit";
import type { FilmState } from "../type/FilmStore";

const initialState: FilmState = {
  film: localStorage.film ? JSON.parse(localStorage.film) : {}
}

const filmSlice = createSlice({
  name: 'film',
  initialState,
  reducers: {
    setFilm(state, action) {
      state.film = action.payload
      localStorage.film = JSON.stringify(action.payload)
    }
  }
})

export const { setFilm } = filmSlice.actions
export default filmSlice
